package com.gerryrun.workserviceapplication.simple

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gerryrun.itemscrollapplication.databinding.SubItemLayoutBinding
import com.gerryrun.itemscrollapplication.simple.SubItem

class NestedAdapter(private val subItems: List<SubItem>) :
    RecyclerView.Adapter<NestedAdapter.NestedViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NestedViewHolder {
        return NestedViewHolder(SubItemLayoutBinding.inflate(LayoutInflater.from(parent.context)))
    }

    override fun onBindViewHolder(holder: NestedViewHolder, position: Int) {
        holder.bind(subItems[position])
    }

    override fun getItemCount(): Int = subItems.size

    inner class NestedViewHolder(itemView: SubItemLayoutBinding) :
        RecyclerView.ViewHolder(itemView.root) {

        fun bind(subItem: SubItem) {
//            nameTextView.text = "${subItem.name}${subItem.name}${subItem.name}${subItem.name}"
        }
    }
}
